<template>
  <div class="app-container">
    <el-drawer
      :title="title"
      :visible.sync="openDetail"
      size="60%"
      @close="cancel"
      :append-to-body="true"
    >
      <!-- <el-dialog
      title="产品BOM物料选择"
      v-if="openDetail"
      :visible.sync="openDetail"
      :modal="false"
      width="60%"
      center
      :close-on-click-modal="false"
      >-->
      <div style="padding: 0 20px">
        <div>
          <el-form ref="form" :model="form" label-width="100px" :rules="rules">
            <el-row>
              <el-col :span="24">
                <el-form-item label="驳回类型：" prop="rejectType">
                  <el-radio-group v-model="form.rejectType">
                    <el-radio :label="0">驳回返修</el-radio>
                    <el-radio :label="1">驳回返工</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="驳回原因：" prop="rejectReason">
                  <el-input
                    v-model="form.rejectReason"
                    type="textarea"
                    placeholder="请输入原因"
                    style="width: 450px; height: 50px"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="success" @click="handleProductQuantity">确定</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </div>
      </div>
      <!-- </el-dialog> -->
    </el-drawer>
  </div>
</template>
        
  <script>
import { addQcLineRejectRecords } from "@/api/mes/qc/qcipqcAll";
export default {
  data() {
    return {
      openDetail: false,
      title: "产线驳回",
      // 表单参数
      form: {},
      requisitionForm: {
        snList: []
      },
      loading: false,
      qcLineSubmissionDetails: {},
      data: {},
      rules: {
        rejectType: [
          { required: true, message: "驳回类型不能为空", trigger: "change" }
        ],
        workorderName: [
          { required: true, message: "工单名称不能为空", trigger: "blur" }
        ]
      },
      qcIpqcallInspectionRecords:{},
    };
  },
  methods: {
    //初始化函数
    init(row, data,obj) {
      console.log(row, data, "子组件的row");
      this.qcIpqcallInspectionRecords = obj || {}
      this.qcLineSubmissionDetails = row;
      this.openDetail = true;
      this.data = data;
      //   this.getList();
    },

    // 取消按钮
    cancel() {
      this.openDetail = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.requisitionForm = {
        rejectType: null,
        rejectReason: null
      };
      this.autoGenFlag = false;
      this.snList = [];
      this.resetForm("requisitionForm");
    },

    // 生成汇报单
    handleProductQuantity() {
      // workorderSnList
      let QcLineSubmissionDetailsDto = {
        qcLineRejectRecords: this.form,
        qcLineSubmissionDetails: this.qcLineSubmissionDetails,
        qcIpqcallInspectionRecords:this.qcIpqcallInspectionRecords
      };
      this.$refs.form.validate(valid => {
        if (valid) {
          addQcLineRejectRecords(QcLineSubmissionDetailsDto).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.openDetail = false;
            this.reset();
            this.$emit("getlineList", this.data);
            // this.getList();
          });
        }
      });
    }
  }
};
</script>
    <style rel="stylesheet/scss" lang="scss" scoped>
.app-container ::v-deep .el-drawer__header {
  padding-top: 10px !important;
  padding-bottom: 5px !important;
  margin-bottom: 10px !important;
}
.dialog-footer {
  padding-top: 10px;
  text-align: right;
}
.titleDiv {
  font-weight: 700 !important;
  font-size: 20px;
}
</style>